# core 源文件描述
file(GLOB CORE_SRC
    ${CMAKE_CURRENT_SOURCE_DIR}/src/*.c
)
# 构建项目
add_executable(${ELF_TARGET}
    ${CORE_SRC}
    ${STARTUP_FILE}
    )

target_compile_definitions(${ELF_TARGET} PUBLIC -D${MCU_FAMILY})
target_include_directories(${ELF_TARGET} PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}/include
)
target_link_libraries(${ELF_TARGET} PUBLIC cmsis stm32f4xx_stdperiph bsp freertos_kernel freertos_config -lc -lm)
target_link_libraries(${ELF_TARGET} PRIVATE -T${LINKER_SCRIPT} ${EXTRA_LINK_FLAGS})

# 项目后处理
include(${PROJ_CMAKE_DIR}/postbuild.cmake)
# 添加子目录
add_subdirectory(${PROJ_DRIVER_DIR}/CMSIS ${PROJ_BUILD_DIR}/driver/cmsis)
add_subdirectory(${PROJ_DRIVER_DIR}/STM32F4xx_StdPeriph_Driver ${PROJ_BUILD_DIR}/driver/stm32f4xx_stdperiph)
add_subdirectory(${PROJ_THIRD_PART_DIR}/FreeRTOS/FreeRTOS-Kernel/examples/cmake_example ${PROJ_BUILD_DIR}/third_parties/FreeRTOS/FreeRTOS-Kernel)
add_subdirectory(${PROJ_BSP_DIR} ${PROJ_BUILD_DIR}/bsp)